#!/bin/sh
. $HOME/.config/defaultprograms.txt
case "$1" in
 -default)
 echo $WORDPROCESSOR > $HOME/.config/tmp/wp
 
 programchooser $WORDPROCESSOR gtk-preferences WordProcessor None > $HOME/.config/tmp/wordprocessor
 cat $HOME/.config/defaultprograms.txt | grep -v WORDPROCESSOR > $HOME/.config/defaultprograms.new
 WORDPROCESSOR="`cat $HOME/.config/tmp/wordprocessor`"
 [ "$WORDPROCESSOR" = "" ] && WORDPROCESSOR="cat $HOME/.config/tmp/wp"
 echo WORDPROCESSOR=\"$WORDPROCESSOR\" >> $HOME/.config/defaultprograms.new
 mv -f $HOME/.config/defaultprograms.new $HOME/.config/defaultprograms.txt
 rm -f $HOME/.config/tmp/wp
 rm -f $HOME/.config/tmp/wordprocessor
 ;;
 *)
 exec $WORDPROCESSOR "$@"
 ;;
esac
exec $WORDPROCESSOR "$@"
